import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PositionVO, PositionForm, PositionQuery } from '@/api/device/position/types';

/**
 * 查询场地信息列表
 * @param query
 * @returns {*}
 */

export const listPosition = (query?: PositionQuery): AxiosPromise<PositionVO[]> => {
  return request({
    url: '/device/position/list',
    method: 'get',
    params: query
  });
};

export const allPosition = (): AxiosPromise<PositionVO[]> => {
  return request({
    url: '/device/position/all',
    method: 'get'
  });
};

/**
 * 查询场地信息详细
 * @param positionId
 */
export const getPosition = (positionId: string | number): AxiosPromise<PositionVO> => {
  return request({
    url: '/device/position/' + positionId,
    method: 'get'
  });
};

/**
 * 新增场地信息
 * @param data
 */
export const addPosition = (data: PositionForm) => {
  return request({
    url: '/device/position',
    method: 'post',
    data: data
  });
};

/**
 * 修改场地信息
 * @param data
 */
export const updatePosition = (data: PositionForm) => {
  return request({
    url: '/device/position',
    method: 'put',
    data: data
  });
};

/**
 * 删除场地信息
 * @param positionId
 */
export const delPosition = (positionId: string | number | Array<string | number>) => {
  return request({
    url: '/device/position/' + positionId,
    method: 'delete'
  });
};
